<?php
namespace app\content\controller;
use think\admin\Controller;
use app\index\model\Banner as BannerModel;
use app\index\model\Crane;
use app\index\model\DataUser;
use app\index\model\Plan as ModelPlan;
use app\index\model\Role;
use app\index\model\Users;
use think\admin\helper\QueryHelper;

class Plan  extends Controller{

     /**
     * @auth true
     * @menu true
     */
    public function index(){
        $search = input('get.');
        $this->carne_list       = Crane::select();
        ModelPlan::mQuery()->layTable(function () {
            $this->title = '计划列表';
        }, function (QueryHelper $query) use ($search) {
            // 数据列表搜索过滤
            $query->with(['crane','segment','stage'])->append(['status_text']);
            $query->equal('crane_id')->like('segment_type_no,produce_no');
        });
    }

     /**
     * @auth true
     * @menu true
     */
    public function edit()
    {
        $this->title = '编辑';
        $this->role_list = Role::select();
        // MyModel::mForm('form');
        $this->_form('plan','form');
    }

     /**
     * @auth true
     * @menu true
     */
    public function add()
    {
        $this->title = '添加';
        $this->role_list = Role::select();
        $this->_form('plan','form');
    }

    public function _form_filter(array &$data){
        if ($this->request->isPost()) {
            $data['password'] = md5($data['password'].'123456789');
            if(Users::where('mobile',$data['mobile'])->find()){
                return $this->error('手机号已存在');
            }
        }
        
    }

    public function remove()
    {
        $this->_delete('plan');
    }


}